package com.ht.base.system.biz.client.impl;

import com.ht.base.system.biz.manager.SysRoleManager;
import com.ht.base.system.client.SysRoleClient;
import com.ht.base.system.common.pojo.bo.SysRoleBO;
import com.ht.base.system.common.pojo.qto.SysRoleQTO;
import org.base.common.appexception.AppException;
import org.base.common.appexception.ResultData;
import org.base.common.page.PageBO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author hdengxian
 * @Date 2023/8/11 8:52
 */
@DubboService
@Component
public class SysRoleClientImpl implements SysRoleClient {
    @Resource
    private SysRoleManager sysRoleManager;

    @Override
    public ResultData<SysRoleBO> insertRole(SysRoleBO roleBO) throws AppException {
        return new ResultData<>(sysRoleManager.insertRole(roleBO));
    }

    @Override
    public ResultData<Boolean> updateRole(SysRoleBO roleBO) throws AppException {
        return new ResultData<>(sysRoleManager.updateRole(roleBO));
    }

    @Override
    public ResultData<Boolean> updateRoleStatus(SysRoleBO roleBO) throws AppException {
        return new ResultData<>(sysRoleManager.updateRoleStatus(roleBO));
    }

    @Override
    public ResultData<Boolean> delRoleByIds(Long[] sysRoleIds) throws AppException {
        return new ResultData<>(sysRoleManager.delRoleByIds(sysRoleIds));
    }

    @Override
    public ResultData<Boolean> delRoleById(Long sysRoleId) throws AppException {
        return new ResultData<>(sysRoleManager.delRoleById(sysRoleId));
    }

    @Override
    public ResultData<SysRoleBO> findRoleById(Long sysRoleId) throws AppException {
        return new ResultData<>(sysRoleManager.findRoleById(sysRoleId));
    }

    @Override
    public ResultData<SysRoleBO> findRoleByUserId(Long sysUserId) throws AppException {
        SysRoleBO roleBO = sysRoleManager.findRoleByUserId(sysUserId);
        return new ResultData<>(roleBO);
    }

    @Override
    public ResultData<PageBO<SysRoleBO>> findRoleForPage(SysRoleQTO qto) throws AppException {
        return new ResultData<>(sysRoleManager.findRoleForPage(qto));
    }
}
